package com.hyfrogx.modules.push.notification;

import cn.hutool.core.util.ObjectUtil;
import com.hyfrogx.modules.push.config.UmConfig;
import com.hyfrogx.modules.push.util.UmPushUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;


@Slf4j
@Data
public class UmIOSNotification extends UmNotification {

    public UmIOSNotification(String type, Map otherParams){
        super(type,otherParams);
        this.setSys(UmConfig.Sys.IOS.name());
        this.setAppMasterSecret(UmConfig.AppMasterSecretIOS);
        if(ObjectUtil.isEmpty(UmConfig.AppKeyIOS)){
            this.getParams().put("appkey","59e5a869f29d9878b900037a");
            this.setAppMasterSecret("xrwnbwrvjnkinx4hy7gontrlwenxmpan");
        }else {
            this.getParams().put("appkey",UmConfig.AppKeyIOS);
        }
        UmPushUtil.setIOSBody(this.getParams());
        //必填参数验证
        this.setBody(this.getParams());
        UmPushUtil.checkBaseParam(this.getBody());
    }

    public void setKeyValue(String key,Object value){
        Map content=this.getBody();
        UmPushUtil.setIOSKeyValue(content,key,value);
    }
}
